﻿// 功能：按钮渐变色
// 描述：
// 作者：温伟鹏
// 日期：2010/6/6 21:12:33

using System;
using System.Drawing;

namespace MeizuSDK.Drawing
{
    /// <summary>
    /// 按钮渐变色
    /// </summary>
    public class GradientButtonColor
    {
        #region 公共属性
        /// <summary>
        /// 获取或设置正常部分渐变色第一种颜色
        /// </summary>
        public Color NormalColor1
        {
            get;
            set;
        }
        /// <summary>
        /// 获取或设置正常部分渐变色第二种颜色
        /// </summary>
        public Color NormalColor2
        {
            get;
            set;
        }
        /// <summary>
        /// 获取或设置正常部分渐变色第三种颜色
        /// </summary>
        public Color NormalColor3
        {
            get;
            set;
        }
        /// <summary>
        /// 获取或设置正常部分渐变色第四种颜色
        /// </summary>
        public Color NormalColor4
        {
            get;
            set;
        }

        /// <summary>
        /// 获取或设置按下部分渐变色第一种颜色
        /// </summary>
        public Color PressedColor1
        {
            get;
            set;
        }
        /// <summary>
        /// 获取或设置按下部分渐变色第二种颜色
        /// </summary>
        public Color PressedColor2
        {
            get;
            set;
        }
        /// <summary>
        /// 获取或设置按下部分渐变色第三种颜色
        /// </summary>
        public Color PressedColor3
        {
            get;
            set;
        }
        /// <summary>
        /// 获取或设置按下部分渐变色第四种颜色
        /// </summary>
        public Color PressedColor4
        {
            get;
            set;
        }
        #endregion

        #region 构造函数
        /// <summary>
        /// 构造按钮渐变色
        /// </summary>
        public GradientButtonColor()
        {

        }
        #endregion

        #region 函数
        /// <summary>
        /// 将按钮渐变颜色转换为MzFC支持的按钮渐变色结构
        /// </summary>
        /// <returns></returns>
        public NativeGradientButtonColor ToGBC()
        {
            uint clr1 = (uint)MzDrawHelper.GetRGB(NormalColor1);
            uint clr2 = (uint)MzDrawHelper.GetRGB(NormalColor2);
            uint clr3 = (uint)MzDrawHelper.GetRGB(NormalColor3);
            uint clr4 = (uint)MzDrawHelper.GetRGB(NormalColor4);
            uint clrs1 = (uint)MzDrawHelper.GetRGB(PressedColor1);
            uint clrs2 = (uint)MzDrawHelper.GetRGB(PressedColor2);
            uint clrs3 = (uint)MzDrawHelper.GetRGB(PressedColor3);
            uint clrs4 = (uint)MzDrawHelper.GetRGB(PressedColor4);

            NativeGradientButtonColor ngbc = new NativeGradientButtonColor();
            ngbc.cr1 = clr1;
            ngbc.cr2 = clr2;
            ngbc.cr3 = clr3;
            ngbc.cr4 = clr4;

            ngbc.cr1s = clrs1;
            ngbc.cr2s = clrs2;
            ngbc.cr3s = clrs3;
            ngbc.cr4s = clrs4;
            return ngbc;
        }
        /// <summary>
        /// 根据给定的颜色值来获取按钮渐变色
        /// </summary>
        /// <param name="clr1">普通状态颜色1</param>
        /// <param name="clr2">普通状态颜色2</param>
        /// <param name="clr3">普通状态颜色3</param>
        /// <param name="clr4">普通状态颜色4</param>
        /// <param name="clrs1">按下状态颜色1</param>
        /// <param name="clrs2">按下状态颜色2</param>
        /// <param name="clrs3">按下状态颜色3</param>
        /// <param name="clrs4">按下状态颜色4</param>
        /// <returns>返回按钮渐变填充颜色</returns>
        public static GradientButtonColor FromGBC(uint clr1,uint clr2,uint clr3,uint clr4,uint clrs1,uint clrs2,uint clrs3,uint clrs4)
        {
            GradientButtonColor gbc = new GradientButtonColor();
            gbc.NormalColor1 = MzDrawHelper.ConvertRgbToColor((int)clr1);
            gbc.NormalColor2 = MzDrawHelper.ConvertRgbToColor((int)clr2);
            gbc.NormalColor3 = MzDrawHelper.ConvertRgbToColor((int)clr3);
            gbc.NormalColor4 = MzDrawHelper.ConvertRgbToColor((int)clr4);

            gbc.PressedColor1 = MzDrawHelper.ConvertRgbToColor((int)clrs1);
            gbc.PressedColor2 = MzDrawHelper.ConvertRgbToColor((int)clrs2);
            gbc.PressedColor3 = MzDrawHelper.ConvertRgbToColor((int)clrs3);
            gbc.PressedColor4 = MzDrawHelper.ConvertRgbToColor((int)clrs4);

            return gbc;
        }
        /// <summary>
        /// 根据给定的颜色值来获取按钮渐变色
        /// </summary>
        /// <param name="ngbc"></param>
        /// <returns>返回按钮渐变填充颜色</returns>
        public static GradientButtonColor FromGBC(NativeGradientButtonColor ngbc)
        {
            return FromGBC(ngbc.cr1, ngbc.cr2, ngbc.cr3, ngbc.cr4,
                ngbc.cr1s, ngbc.cr2s, ngbc.cr3s, ngbc.cr4s);
        }
        #endregion
    }
}
